using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using System.Data;

namespace HeThongDAO
{
    public class PhieuNhapDAO
    {
        public static System.Data.DataTable DocSchema(string strQuery)
        {
            return Config.AccessHelper.Doc_Cau_Truc_HungPham(strQuery);
        }

        public static bool ThemPhieuNhap(PhieuNhapDTO pnDTO)
        {
            try
            {
                string sql = "INSERT INTO PHIEU_NHAP(NgayNhap) ";
                sql += "VALUES("  + "'" + pnDTO.INgayNhap.ToString() + "')";
                sql = sql.Replace(pnDTO.INgayNhap.ToString(), pnDTO.INgayNhap.ToString("MM/dd/yyyy"));

                int maPN = (int)Config.AccessHelper.ExecuteNonQuery_Scalar(sql);
                pnDTO.IMaPhieuNhap = maPN;
                return true;
            }
            catch
            {
                return false;
            }
        }

        public static DataTable LayTatCaPhieuNhap()
        {
            string sql = "SELECT * FROM PHIEU_NHAP";
            return Config.AccessHelper.ExecuteQuery(sql);
        }
    }
}
